home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / (A)G / (A)G6.ADF / robatusen < prev    next >
Text File  |  1988-05-24  |  8KB  |  236 lines

  1.  
  2. equate count 0
  3. equate dist  1
  4. equate tempa 2
  5. equate tempb 3
  6. equate tempc 4
  7. equate xtarg 5
  8. equate ytarg 6
  9. equate xdrd  7
  10. equate ydrd  8
  11. equate flag  9
  12. equate width 10
  13. equate angle 11
  14. equate scwidth 12
  15. equate scangle 13
  16. equate scflag  14
  17. equate tdist   15
  18. equate xfire   16
  19. equate yfire   17
  20. equate xvel    18
  21. equate yvel    19
  22. equate scnmv   3        \ how far it moves between time it records x,y \
  23.                         \ and the time it scans \
  24. equate frmv    8        \ how far it moves between the time it scans \
  25.                         \ and the time it fires \
  26.  
  27. cpu 2x32bit
  28.  
  29. drive track 70
  30.  
  31. weapon lgun   60 150
  32. weapon lgun   60 150
  33. weapon lgun   60 150
  34. weapon lgun   60 150
  35.  
  36. reg 20
  37.  
  38. # 50 sto xtarg sto ytarg
  39. sto scwidth
  40. # 0 sto scflag
  41.  
  42. # 180 sto count               \ figure out closest wall, assume left \
  43. # 50 posx sto tempa           \ dist to left wall \
  44. x<y? goto jlp1                \ if posx<50?, go left \
  45. # 100 swap - sto tempa        \ dist to right wall \
  46. # 0 sto count                 \ go right \
  47. label jlp1
  48.  
  49. # 270 sto tempb               \ assume bottom wall \
  50. # 50 posy sto tempc           \ dist to bottom wall \
  51. x<y? goto jlp2                \ if posy<50?, go down \
  52. # 100 swap - sto tempc        \ dist to top wall \
  53. # 90 sto tempb                \ go up \
  54. label jlp2
  55.  
  56. rcl tempa                     \ dist left-right \
  57. rcl tempc                     \ dist up-down \
  58. x>y? goto jlp3                \ if left-right is closer than up-down,\
  59. rcl tempb sto count           \ then use it, else use up-down. \
  60. label jlp3
  61.  
  62. \************************** look ahead ***********************\
  63.  
  64. label lookah                    \ look where you're about to go \
  65. rcl count sin sto yvel        \ plus or minus 1 or 0 for y velocity \
  66. rcl count cos sto xvel
  67. # 10 sto width
  68. rcl count sto angle radar     \ scan in direction of travel (count) \
  69. x<0? goto jmpov1              \ don't look if there's nothing to look at. \
  70. gosub halffi                  \ if there's something there, kill it! \
  71. rcl flag # 1 x=y? goto lookah \ if found and lost something, look again \
  72.  
  73. label jmpov1
  74. # 10 sto width                \ be paranoid, check behind \
  75. rcl count # 180 + sto angle
  76. radar
  77. x<0? goto jmpov2              \ don't look for nothing. \
  78. gosub halffi                  \ haha! I knew it was there! \
  79. rcl flag # 1 x=y? goto lookah \ there may be more of them out there, \
  80.                               \ I just know it. \
  81. label jmpov2
  82.  
  83. \************************** move along walls **************************\
  84.  
  85. label forwar                    \ go forward!!! \
  86. rcl count heading
  87.  
  88. rcl count # 80 x<y? goto grp1 \ if going right... \
  89. posx sto xdrd sto xfire
  90. posy sto ydrd sto yfire
  91. # 100 rcl xdrd - speed        \ set right speed \
  92. # 7 x>y? goto turn            \ turn if close to edge \
  93. # scnmv sto+ xdrd             \ where it will be \
  94. # frmv sto+ xfire
  95. gosub dodada                  \ scan 360, aim and fire \
  96. goto forwar                   \ move on \
  97.  
  98. label grp1
  99. rcl count # 170 x<y? goto grp2 \ if going up... \
  100. posx sto xdrd sto xfire
  101. posy sto ydrd sto yfire
  102. # 100 rcl ydrd - speed        \ set up speed \
  103. # 7 x>y? goto turn            \ turn if close to edge \
  104. # scnmv sto+ ydrd             \ where it will be \
  105. # frmv sto+ yfire
  106. gosub dodada                  \ scan, aim, fire \
  107. goto forwar                   \ move on \
  108.  
  109. label grp2
  110. rcl count # 260 x<y? goto grp3 \ if going left... \
  111. posx sto xdrd sto xfire
  112. posy sto ydrd sto yfire
  113. rcl xdrd speed                \ set left speed \
  114. # 7 x>y? goto turn            \ turn if close to edge \
  115. # scnmv sto- xdrd             \ where it will be \
  116. # frmv sto- xfire
  117. gosub dodada                  \ scan, aim, fire \
  118. goto forwar                   \ move on \
  119.  
  120. label grp3                      \ obviously going down... \
  121. posx sto xdrd sto xfire
  122. posy sto ydrd sto yfire
  123. rcl ydrd speed                \ set down speed \
  124. # 7 x>y? goto turn            \ turn if close to edge \
  125. # scnmv sto- ydrd             \ where it will be \
  126. # frmv sto- yfire
  127. gosub dodada                  \ scan, aim, fire \
  128. goto forwar                   \ move on \
  129.  
  130. \*************************** turn around **************************\
  131.  
  132. label turn                      \ turn around \
  133. # 0 speed
  134. # 350
  135. rcl count # 90 +              \ turn by 90 degrees \
  136. x>y? # 0                      \ if count<350, use it; otherwise set to 0 \
  137. sto count goto lookah         \ check ahead and move on \
  138.  
  139. \************************* figure it all out.. **********************\
  140.  
  141. label dodada                   \ scflag:   0: scan at scangle \
  142.                              \           1: scan left one width \
  143.                              \           2: scan right one width \
  144. rcl ytarg rcl ydrd -         \ delta y \
  145. rcl xtarg rcl xdrd -         \ delta x \
  146. atan2 sto scangle            \ angle to scan at \
  147. rcl scflag x=0? goto isalri  \ if it's ok to scan there, do so \
  148. # 1.5 x>y? goto lkleft       \ if scflag=1, scan to left \
  149. rcl scangle rcl scwidth -    \ else look to the right one width \
  150. sto scangle goto isalri      \ and go to scan there \
  151. label lkleft
  152. rcl scangle rcl scwidth +    \ going to look left one width \
  153. sto scangle
  154.  
  155. label isalri
  156. rcl scwidth rcl scangle      \ get width and angle \
  157. radar x>0? goto isinbeam     \ something is in the beam \
  158. rcl scflag # 1 +             \ increment scflag by 1 \
  159. # 3 x!=y? return             \ if not 3, keep moving \
  160. # 2 sto* scwidth             \ double scan width \
  161. # 1 sto scflag               \ set to look left next time we're here \
  162. return                       \ go back to moving \
  163.  
  164. label isinbeam
  165. sto tdist
  166. rcl scangle sin *
  167. rcl ydrd + sto ytarg         \ new y coordinate for target \
  168. rcl scangle cos rcl tdist *
  169. rcl xdrd + sto xtarg         \ new x coordinate for target \
  170.  
  171. # 0 sto scflag               \ reset scflag for next time through \
  172. # .6 rcl scwidth *
  173. # 4 rcl tdist / r-d          \ angular width of 4 meter at tdist \
  174. x<y? swap                    \ don't let the width become too small \
  175. sto scwidth                  \ cut scan width to .7 of its value \
  176. d-r rcl tdist *              \ width of beam in meters at distance of droid \
  177. # 6 x<y? return              \ if not within 6 meters, don't fire. \
  178. rcl tdist # 10 / sto tempa   \ dist shot will drift from \
  179.                              \ includes speed of shot and speed of droid \
  180. rcl xtarg rcl xfire - rcl tempa rcl xvel * -  sto tempb
  181. rcl ytarg rcl yfire - rcl tempa rcl yvel * -  rcl tempb
  182. atan2 aim
  183. rcl tdist
  184. fire 0 fire 1 fire 2 fire 3  \ nuke the damn thing! \
  185. return                       \ try again \
  186.  
  187.  
  188. \**************************************************************************\
  189.  
  190. label halffi                   \ subroutine, pass in: width
  191.                                                     angle
  192.                                            returns: flag 0: found nothing
  193.                                                          1: found and lost
  194.                                                          2: got hit here   \
  195. sto dist                     \ save dist for later use \
  196. rcl width # .6
  197. x>y? goto adjus              \ if less than .6 deg., fire \
  198. rdn # 2 / sto width          \ half the width \
  199. sto+ angle                   \ scan to the left \
  200. rcl angle radar
  201. x>0? goto halffi             \ if something there, keep going \
  202. rcl width # 2 * sto- angle   \ scan to right \
  203. rcl width rcl angle radar
  204. x>0? goto halffi             \ if something there, keep going \
  205. # 0 sto flag return          \ found nothing to shoot at, return. \
  206.  
  207. label adjus
  208. rcl angle
  209. # 1.5 rcl dist / atan
  210. sto- angle                   \ move to the right a bit. \
  211. rcl angle aim
  212. rcl dist
  213.  
  214. label fire1
  215. sto dist
  216. fire 0 fire 1                \ fire dead on. \
  217. fire 2 fire 3
  218. rcl angle aim aim            \ delay \
  219. # 0 rcl angle                \ is it still there? \
  220. radar x>0? goto fire1
  221.  
  222. # 3 rcl dist / atan
  223. sto width                    \ four droid widths \
  224. enter rcl angle + sto angle  \ look to the left. \
  225. radar x>0? goto halffi       \ if it's there, find it. \
  226. rcl width enter # 2 *
  227. rcl angle swap - sto angle   \ look to the right. \
  228. rcl width rcl angle radar
  229. x>0? goto halffi              \ if it's there, find it. \
  230.  
  231. # 1 sto flag                 \ lost it. \
  232. return
  233. \**************************************************************************\
  234.  
  235.  
  236.